<?php
namespace app\index\model;
use app\index\validate\Tablea as TableaValidate;
class tableA extends Common
{
	protected $table = 'tablea';
	
	public function adddata($data){
	/* 	$validate = new TableaValidate();
		$validate = Validate::make([
		    'platform'=>'require',
		    'order_number'=>'require',
		    'delivery_time'=>'require',
		    'receiving_information'=>'require',
		    'express_company'=>'require',
		    'hwb_number'=>'require',
		    'status'=>'require',
		    'after_sales_reason'=>'require'
		]);
		if(!$validate->check($data)){
			return $this->message('400',$validate->getError());
		} */
		$res = tableA::create($data);
		if($res){
			return $this->message('200','添加成功');
		}else{
			return $this->message('400','添加失败');
		}
	}
	public function editdata($data){
		$res = tableA::update($data,$data['id']);
		if($res){
			return $this->message('200','更新成功');
		}else{
			return $this->message('400','更新失败');
		}
	}
	public function del($id){
		$res = tableA::get($id)->delete();
		if($res){
			return $this->message('200','删除成功');
		}else{
			return $this->message('400','删除失败');
		}
	}
	public function searchOrderNumberAttr($query, $value, $data)
	   {
	      /* $query->where('order_number','like','%'. $value .'%'); */
		  $query->where('order_number','like', $value . '%');
	   }
	public function searchHwbNumberAttr($query, $value, $data)
	   {
	       $query->where('hwb_number','like', $value .'%');
	   }
}